﻿// ==================================================
// Copyright © 2016 杭州伯庸科技 版权所有
//
// 文 件 名：FlyViewer
// 功能描述：
//
// 创建标识：Yu.Liang(俞 亮) 2018/3/8 14:09:40
//
// 修改标识：
// 修改描述：
// ==================================================

using Shine.Framework;
using SuperMap.Realspace;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Shine.Viewer
{
    public class FlyViewer : BaseCommand
    {
        IApplication m_Application = null;

        public FlyViewer()
        {
            base.m_caption = "飞行视角";
            base.m_name = "FlyViewer";
            base.m_toolTip = "飞行视角";
            base.m_message = "飞行视角";
            base.m_category = "Viewer";
        }

        public override void OnCreate(object hook)
        {
            if (m_Application == null)
            {
                m_Application = hook as IApplication;
            }
        }

        public override void OnClick()
        {
            Camera c = (m_Application as IFramework).SceneControl.Scene.Camera;
            c.Heading = 0;
            (m_Application as IFramework).SceneControl.Scene.Camera = c;

            Camera c2 = (m_Application as IFramework).SceneControl2.Scene.Camera;
            c2.Heading = 0;
            (m_Application as IFramework).SceneControl2.Scene.Camera = c2;
        }

        public override int Bitmap
        {
            get
            {
                string imgFile = Application.StartupPath + "\\Images\\" + GetType().Name + ".png";

                if (System.IO.File.Exists(imgFile) == false) return 0;

                return new Bitmap(Image.FromFile(imgFile)).GetHbitmap().ToInt32();
            }
        }


        public override bool Enabled
        {
            get
            {
                return
                    //(m_Application as IFramework).SceneControl.Scene != null ||
                    //(m_Application as IFramework).SceneControl2.Scene != null;
                    false;
            }
        }
    }
}
